import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:yp/pages/order_settlement/widgets/style.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class EsIconButton extends StatelessWidget {
  final Widget icon;
  final double iconSize;
  final EdgeInsetsGeometry padding;
  final Function onTap;
  const EsIconButton(this.icon,
      {Key key,
      this.iconSize = 24.0,
      this.padding = EdgeInsets.zero,
      this.onTap})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return IconButton(
      icon: icon,
      iconSize: iconSize,
      padding: padding,
      constraints: BoxConstraints(minHeight: 0, minWidth: 0),
      onPressed: onTap,
    );
  }
}


/// 横线
class YpLine extends StatelessWidget {
  /// 起点缩进距离
  final double indent;

  /// 终点缩进距离
  final double endIndent;

  /// 分割线区域的高度，并非分割线的高度
  final double height;

  /// 分割线的厚度，真正的分割线的高度
  final double thickness;

  /// 分割线颜色
  final Color color;

  const YpLine({
    this.indent = 0,
    this.endIndent = 0,
    this.height = 1,
    this.thickness = 1,
    this.color = const Color(0xFFefefef),
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Divider(
        indent: indent,
        endIndent: endIndent,
        height: height.w,
        thickness: thickness.w,
        color: color);
  }
}
class EsBottomWidget extends StatelessWidget {
  final String leftTitle;
  final String rightTitle;
  final double fontSize;
  final Function() leftClick;
  final Function() rightlick;
  final Decoration decoration;
  const EsBottomWidget(
      {Key key,
      @required this.leftTitle,
      @required this.rightTitle,
      this.leftClick,
      this.rightlick,
      this.decoration = EsDecoration.BoxShadowRadiusUp,
      this.fontSize = EsSizes.LG})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.fromLTRB(0, 10, 0, 10),
      decoration: decoration,
      child: Row(
        mainAxisSize: MainAxisSize.max,
        children: <Widget>[
          const SizedBox(
            width: 16,
          ),
          Visibility(
            visible: leftTitle?.isNotEmpty ?? false,
            child: Expanded(
              child: OutlinedButton(
                style: OutlinedButton.styleFrom(
                  primary: EsColors.White,
                  minimumSize: Size(MediaQuery.of(context).size.width - 32, 44),
                  shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(6)),
                  side: BorderSide(color: EsColors.Primary, width: 1),
                ),
                onPressed: leftClick ?? () {},
                child: Text(
                  leftTitle ?? '',
                  style: TextStyle(
                      fontSize: fontSize,
                      color: EsColors.Primary,
                      fontWeight: EsFontWeights.Normal),
                ),
              ),
            ),
          ),
          const SizedBox(
            width: 10,
          ),
          Expanded(
              child: Container(
            decoration: BoxDecoration(
              gradient: LinearGradient(
                ///渐变色
                colors: [Color(0xfffe8e33), EsColors.Primary],
              ),
              borderRadius: BorderRadius.all(
                  Radius.circular((leftTitle?.isEmpty ?? true) ? 23 : 6)),
            ),
            child: TextButton(
              style: TextButton.styleFrom(
                minimumSize: Size(MediaQuery.of(context).size.width - 32, 44),
              ),
              onPressed: rightlick ?? () {},
              child: Text(
                rightTitle ?? '',
                style: TextStyle(
                    color: Colors.white,
                    fontSize: fontSize,
                    fontWeight: EsFontWeights.Normal),
              ),
            ),
          )),
          const SizedBox(
            width: 16,
          ),
        ],
      ),
    );
  }
}


